﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System.Runtime.Serialization;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Specialized;
using System.Collections;
using System.ComponentModel;
using System.Windows;
using System;
using System.IO;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrainTechLLC.ThreadSafeObjects;
using System.Collections.ObjectModel;

namespace BrainTechLLC
{
    public partial class GameThingBaseClass : BaseClass, IKeywordAccessible, INameAndDescription, IHasNameAndDescription, IGameThing, IHasPropertyData, ICanBePlacedInWorld, ICanSaveAndRestore, INotifyPropertyChanged, IFromTemplate, INotifyPropertyChanging, INotifyCollectionChanged
    {        
        [DataMember]
        public long _location;
      
        [NonSerialized, XmlIgnore]
        public Template _templateObject;

        [NonSerialized, XmlIgnore]
        public bool _isPlaced;

        [Category("World")]
#if NO_SILVERLIGHT
        [EditorBrowsable(EditorBrowsableState.Always)]
#endif
        [XmlIgnore]
        public bool IsPlaced
        {
            get { return _isPlaced; }
            set
            {
                if (!_isPlaced.AreEqual(value))
                {
                    OnPropertyChanging("IsPlaced", _isPlaced, value);
                    _isPlaced = value;
                    OnPropertyChanged("IsPlaced", _isPlaced, value);
                }

            }
        }

        [Category("World")]
#if NO_SILVERLIGHT
        [EditorBrowsable(EditorBrowsableState.Always)]
#endif
        [XmlIgnore]        
        public long Location
        {
            get { return _location; }
            set
            {
                if (!_location.AreEqual(value))
                {
                    OnPropertyChanging("Location", _location, value);
                    _location = value;
                    OnPropertyChanged("Location", _location, value);
                }
            }
        }

#if NO_SILVERLIGHT
        [Browsable(true)]
        [TypeConverter(typeof(ExpandableObjectConverter))]
        [EditorBrowsable(EditorBrowsableState.Always)]
#endif
        [XmlIgnore]
        public virtual StateCollection States
        {
            get { return null; }
            set { }
        }

        [XmlIgnore]
        public virtual ObservableCollection<Ability> ObservableAbilities
        {
            get
            {
                return null;
            }
        }

        [XmlIgnore]
        public virtual ObservableCollection<State> ObservableStates
        {
            get
            {
                return (States == null) ? new ObservableCollection<State>() :
                    States.Find<State>().ToObservable();
            }
        }

        [XmlIgnore]
        public string TypeName
        {
            get { return this.GetType().Name; }
        }
    }
}
